import {
  createStoreBindings
} from "mobx-miniprogram-bindings"
import {
  store
} from "../../store/store"
Page({
  /**
   * 页面的初始数据
   */
  data: {
    url: '/pages/settings/settings'
  },

  // 跳转到登录页面
  toLoginPage() {
    if (this.data.token) {
      var url = '/pages/settings/settings'
    } else {
      var url = '/pages/login/login'
    }
    wx.navigateTo({
      url
    })
      
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log("onLoad");
    this.storeBindings = createStoreBindings(this, {
      store,
      fields: ["userinfo", "token"]
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
    console.log("  onReady");

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.storeBindings = createStoreBindings(this, {
      store,
      fields: ["userinfo", "token"]
    })
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {
    this.storeBindings.destroyStoreBindings()

  },

})